package com.game.server.message.proto.execute;

import com.comm.ISession;

import com.game.majiang.config.DataManager;
import com.game.majiang.logic.LogicClient;
import com.game.majiang.logic.LogicServer;
import com.game.server.db.entity.XyClubInfo;
import com.game.server.db.entity.XyClubMemberInfo;
import com.game.server.message.proto.in.AbstractXYclubContributionUpdateReq;
import com.game.server.message.proto.out.XYclubContributionUpdateRsp;

public class XYclubContributionUpdateReq extends AbstractXYclubContributionUpdateReq {

    @Override
    public void Execute(ISession session) {
        LogicClient client = (LogicClient) LogicServer.getInstance().getClient(session.getId());
        if (client != null&&client.checkClick(msgcode)) {
            XYclubContributionUpdateRsp rsp = new XYclubContributionUpdateRsp();
            rsp.setUid(this.uid);
            rsp.setIsok(1);
            rsp.setType(this.type);
            rsp.setValue(this.value);
            XyClubInfo clubInfo = DataManager.getInstance().getMapClub().get(this.clubid);
            if (clubInfo!=null){
                XyClubMemberInfo meMemberInfo = clubInfo.getPlayer().get(client.getUserId());
                if (meMemberInfo!=null && (meMemberInfo.getIsManager()==1 || meMemberInfo.getIsManager()==2)){
                    XyClubMemberInfo toMemberInfo = clubInfo.getPlayer().get(this.uid);
                    if (toMemberInfo!=null){
                        if (this.type==1 || this.type==2){
                            int isok = toMemberInfo.updateXingyuvalue(this.type, this.value, 0, meMemberInfo.getUid(), 0,0);
                            rsp.setIsok(isok);
                        }
                    }
                }
            }
            client.Send(rsp);
        }
    }

}
